package com.panfeng.xcloud.boss.provider.member.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.panfeng.xcloud.boss.provider.member.dto.request.QueryCommonInfoReqDTO;
import com.panfeng.xcloud.boss.provider.member.dto.response.QueryCommonInfoRespDTO;
import com.panfeng.xcloud.boss.provider.member.service.IUserCommonInfoService;
import com.panfeng.xcloud.boss.provider.member.web.vo.request.QueryCommonInfoReqVO;
import com.panfeng.xcloud.boss.provider.member.web.vo.response.QueryCommonInfoRespVO;
import com.panfeng.xcloud.common.core.utils.ConvertUtils;
import com.panfeng.xcloud.common.core.web.vo.ResponseVO;
import com.panfeng.xcloud.common.security.annotation.MethodValidate;
import com.panfeng.xcloud.common.security.annotation.NotNeedAccess;
import com.panfeng.xcloud.common.security.web.support.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 用户公共信息(Banner,公告等)
 *
 * @author xiaobo
 * @version 1.0
 * @since 2019-08-08
 */
//@ApiIgnore
@RestController
@RequestMapping("user/commoninfo")
@Api(tags = {"用户公共信息(Banner,公告等)模块"})
@Slf4j
public class UserCommonInfoController extends BaseController {

    @Autowired
    private IUserCommonInfoService iUserCommonInfoService;

    /**
     * 查询用户公共信息
     *
     * @param queryCommonInfoReqVO
     * @param bindingResult
     * @return
     */
    @MethodValidate
    @NotNeedAccess
    @PostMapping(value = "/queryCommonInfo", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询用户公共信息(肖博)", httpMethod = "POST", notes = "查询用户公共信息(肖博)")
    public ResponseVO<QueryCommonInfoRespVO> queryCommonInfo(@RequestBody @Valid QueryCommonInfoReqVO queryCommonInfoReqVO, BindingResult bindingResult) {
        logger.info(">>>> 当前queryCommonInfo请求参数：{} <<<", (null != queryCommonInfoReqVO ? JSONObject.toJSONString(queryCommonInfoReqVO) : ""));
        QueryCommonInfoReqDTO queryCommonInfoReqDTO = ConvertUtils.convert(queryCommonInfoReqVO, QueryCommonInfoReqDTO.class);
        QueryCommonInfoRespDTO queryCommonInfoRespDTO = iUserCommonInfoService.queryCommonInfo(queryCommonInfoReqDTO);
        QueryCommonInfoRespVO queryCommonInfoRespVO = ConvertUtils.convert(queryCommonInfoRespDTO, QueryCommonInfoRespVO.class);
        logger.info(">>>> 当前queryCommonInfo响应内容：{} <<<", (null != queryCommonInfoRespVO ? JSONObject.toJSONString(queryCommonInfoRespVO) : ""));
        return ResponseVO.with(queryCommonInfoRespVO);
    }

}
